;-----------------------------------------------------------;
(import-class "java.lang.Number")

(defun int (num)
  (java.lang.Number.intValue num))

(defun double (num)
  (java.lang.Number.doubleValue num))

;-----------------------------------------------------------;
(import-class "java.lang.String")

(defun starts-with (string prefix)
  (java.lang.String.startsWith string prefix))

(defun ends-with (string suffix)
  (java.lang.String.endsWith string suffix))

(defun index-of (string target)
  (java.lang.String.indexOf string target))

(defun last-index-of (string target)
  (java.lang.String.lastIndexOf string target))

(defun strlen (string)
  (java.lang.String.length string))

(defun substring (string start end)
  (java.lang.String.substring string (int start) (int end)))

(defun upper-case (string)
  (java.lang.String.toUpperCase string))

(defun lower-case (string)
  (java.lang.String.toLowerCase string))

(defun trim (string)
  (java.lang.String.trim string))

;-----------------------------------------------------------;
(import-class "java.util.List")

(defun nth (n l)
  (java.util.List.get l (int n)))

(defun append (l o)
  (java.util.List.add l o))

(defun sublist (l from to)
  (java.util.List.subList l (int from) (int to)))

(defun length (l)
  (java.util.List.size l))

(defun iterator (l)
  (java.util.List.listIterator l))

;-----------------------------------------------------------;
(import-class "java.util.ListIterator")

(defun has-next (it)
  (java.util.ListIterator.hasNext it))

(defun next (it)
  (java.util.ListIterator.next it))

;-----------------------------------------------------------;
(import-class "jp.tyas.libs.lisp.Symbol")

(defun symbol-name (sym)
  (jp.tyas.libs.lisp.Symbol.getName sym))

(defun symbol-value (sym)
  (jp.tyas.libs.lisp.Symbol.getValue sym))

(defun symbol-function (sym)
  (jp.tyas.libs.lisp.Symbol.getCallee sym))

;-----------------------------------------------------------;
(import-class "java.util.Arrays")

(defun array-to-list (array)
  (java.util.Arrays.asList nil array))

(defun a2l (array)
  (java.util.Arrays.asList nil array))

(defun aget (n array)
  (java.util.Arrays.get nil array (int n)))

(defun aset (n array o)
  (java.util.Arrays.set nil array (int n) o))

;-----------------------------------------------------------;
(import-class "java.lang.System")

(defun get-time ()
  (java.lang.System.currentTimeMillis nil))

(defun time (fn)
  (let ((sta (get-time)))
    (apply fn ())
    (- (get-time) sta)))

(defun system-property (name)
  (java.lang.System.getProperty nil name))

;-----------------------------------------------------------;
(import-class "java.util.Hashtable")

(defun make-hashtable ()
  (new-java.util.hashtable))

(defun hset (h key val)
  (java.util.hashtable.put h key val))

(defun hget (h key)
  (java.util.hashtable.get h key))
